package com.xiangban.yanglaodajie_admin.controller;

import com.xiangban.yanglaodajie_admin.aop.Permission;
import com.xiangban.yanglaodajie_admin.entity.Teacher;
import com.xiangban.yanglaodajie_admin.entity.TeacherShop;
import com.xiangban.yanglaodajie_admin.entity.dto.TeacherDto;
import com.xiangban.yanglaodajie_admin.entity.res.ApiResult;
import com.xiangban.yanglaodajie_admin.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author Mr. MaYaYun
 * @Data 2021/7/8 17:36
 */
@RestController
@RequestMapping("/api/admin/teacher")
@Api(tags = "课程教师管理")
public class TeacherController {

    @Autowired
    private TeacherService teacherService;


    @PostMapping("/TeacherList")
    @ApiOperation("教师信息列表")
    @Permission(permission = "admin:teacher:TeacherList")
    public ApiResult<Object> TeacherList(@RequestBody TeacherDto teacher){
        return ApiResult.newSuccess(teacherService.TeacherList(teacher));
    }

    @PostMapping("/addTeacher")
    @ApiOperation("添加教师信息")
    @Permission(permission = "admin:teacher:addTeacher")
    public ApiResult<Object> addTeacher(@RequestBody TeacherDto teacher){
        teacherService.addTeacher(teacher);
        return ApiResult.newSuccess();
    }

    @PostMapping("/updateTeacher")
    @ApiOperation("修改教师信息")
    @Permission(permission = "admin:teacher:updateTeacher")
    public ApiResult<Object> updateTeacher(@RequestBody TeacherDto teacher){
        teacherService.updateTeacher(teacher);
        return ApiResult.newSuccess();
    }

    @PostMapping("/removeTeacher")
    @ApiOperation("教师删除")
    @Permission(permission = "admin:teacher:removeTeacher")
    public ApiResult<Object> removeTeacher(@RequestBody TeacherDto teacher){
        teacherService.removeTeacher(teacher);
        return ApiResult.newSuccess();
    }

    @PostMapping("/TeacherInfo")
    @ApiOperation("教师信息详情")
    @Permission(permission = "admin:teacher:TeacherInfo")
    public ApiResult<Object> TeacherInfo(@RequestBody Teacher teacher){
        return ApiResult.newSuccess(teacherService.TeacherInfo(teacher));
    }

    @PostMapping("/bindTeacher")
    @ApiOperation("课程教师绑定")
    @Permission(permission = "admin:teacher:bindTeacher")
    public ApiResult<Object> bindTeacher(@RequestBody TeacherShop teacher){
        teacherService.bindTeacher(teacher);
        return ApiResult.newSuccess();
    }

//    @PostMapping("/overBindTeacher")
//    @ApiOperation("课程教师或班长解绑")
//    @Permission(permission = "admin:teacher:overBindTeacher")
//    public ApiResult<Object> overBindTeacher(@RequestBody TeacherShop teacher){
//        teacherService.overBindTeacher(teacher);
//        return ApiResult.newSuccess();
//    }

}
